﻿CREATE TABLE [dbo].[MaterielTypMaterielTyp] (
    [Id]       UNIQUEIDENTIFIER NOT NULL,
    [ValId]    UNIQUEIDENTIFIER NOT NULL,
    [Skapad]   DATETIME         NOT NULL,
    [SkapadAv] NVARCHAR (50)    NOT NULL,
    [Andrad]   DATETIME         NULL,
    [AndradAv] NVARCHAR (50)    NULL,
    [ParentId] UNIQUEIDENTIFIER NOT NULL,
    [ChildId]  UNIQUEIDENTIFIER NOT NULL,
    CONSTRAINT [PK_MaterielTypMaterielTyp] PRIMARY KEY CLUSTERED ([Id] ASC, [ValId] ASC),
    CONSTRAINT [FK_MaterielTypMaterielTyp_MaterielTyp] FOREIGN KEY ([ParentId], [ValId]) REFERENCES [dbo].[MaterielTyp] ([Id], [ValId]),
    CONSTRAINT [FK_MaterielTypMaterielTyp_MaterielTyp1] FOREIGN KEY ([ChildId], [ValId]) REFERENCES [dbo].[MaterielTyp] ([Id], [ValId])
);



